package com.aiyige.page.my.message.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.my.message.model.Contact;
import com.aiyige.utils.GlideUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ContactAdapter extends BaseQuickAdapter<Contact, ContactAdapter.ViewHolder> {
    public ContactAdapter() {
        super(R.layout.contact_item, new LinkedList<Contact>());
    }

    @Override
    protected void convert(ViewHolder helper, Contact item) {
        helper.bindData(item);
    }


    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.avatarIv)
        ImageView avatarIv;
        @BindView(R.id.nameTv)
        TextView nameTv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(Contact contact) {
            GlideUtil.with(itemView.getContext())
                    .loadAvatar(contact.getAvatar())
                    .into(avatarIv);
            nameTv.setText(contact.getName());
        }
    }
}
